import type { CodeType, User, UserInfo, Patient } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('/login/password', 'POST', { mobile, password })

// 发送验证码
export const sendMobileCode = (mobile: string, type: CodeType) =>
  request<{ code: string }>('/code', 'GET', { mobile, type })

// 短信验证码登录
export const loginByMobile = (mobile: string, code: string) =>
  request<User>('/login', 'POST', { mobile, code })

// 获取用户详细信息
export const getUserInfo = () => request<UserInfo>('/patient/myUser', 'GET')

// 获取家庭
export const getPatientList = () => request<Patient[]>('/patient/mylist', 'GET')

// 添加患者
export const addPatient = (patient: Patient) => request('/patient/add', 'POST', patient)

// 编辑患者
export const editPatient = (patient: Patient) => request('/patient/update', 'PUT', patient)

// 删除患者
export const delPatient = (id: string) => request(`/patient/del/${id}`, 'DELETE')

// 获取患者信息
export const getPatientDetail = (id: string) => request<Patient>(`/patient/info/${id}`, 'GET')

// qq登录
export const loginByQQ = (params: { openId: string; source: string }) =>
  request<User>('/login/thirdparty', 'POST', params)

// // 绑定手机号
export const bindMobile = (params: { mobile: string; code: string; openId: string }) =>
  request<User>('/login/binding', 'POST', params)

// 绑定手机号
// export const bindMobile = (data: { mobile: string; code: string; openId: string }) =>
//   request<User>('/login/binding', 'POST', data)
